package com.br.pfm.persistence.model;

import java.io.Serializable;
import java.util.GregorianCalendar;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import lombok.Getter;
import lombok.Setter;

import org.hibernate.annotations.NamedQueries;
import org.hibernate.annotations.NamedQuery;

@NamedQueries({
	@NamedQuery(name = "Instituicao.findInstituicao", query = "select i from Instituicao i where i.idInstituicao = :idInstituicao"),
	@NamedQuery(name = "Instituicao.getAllInstituicoes", query = "select i from Instituicao i"),
	@NamedQuery(name = "Instituicao.editInstituicao", query = "update Instituicao set nomeInstituicao = :nomeInstituicao,"
			+ " diaVencimento = :diaVencimento, diaCorte = :diaCorte, valorSugerido = :valorSugerido,"
			+ " dataFimVigencia = :dataFimVigencia"),
})
@Entity
@Table(name="PFM_instituicao")
public class Instituicao implements Serializable {
	
	private static final long serialVersionUID = -2580768601197082300L;
	
	@Id
	@GeneratedValue
	@Column(name = "id_instituicao", nullable = false, length = 2)
	private int idInstituicao;
	
	@Getter
    @Setter
	@Column(name = "nm_instituicao", nullable = false, length = 30)
	private String nomeInstituicao;
	
	@Getter
    @Setter
	@Column(name = "dia_vencimento", nullable = false, length = 2)
	private int diaVencimento;
	
	@Getter
    @Setter
	@Column(name = "dia_corte", nullable = false, length = 2)
	private int diaCorte;
	
	@Getter
    @Setter
	@Column(name = "valor_sugerido", nullable = false, length = 10)
	private int valorSugerido;
	
	@Getter
    @Setter
	@Column(name = "dt_fim_vigencia", nullable = false, length = 10)
	private GregorianCalendar dataFimVigencia;
	
	@Getter
    @Setter
	@ManyToOne(cascade=CascadeType.ALL)
    private Cliente cliente;
	
	@Getter
	@Setter
	@OneToMany(cascade=CascadeType.ALL)
    @JoinColumn(name="id_instituicao")
    private List<Fatura> faturas;
	
}
